﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using MineSweeper.Data;

namespace MineSweeper.Windows
{
    /// <summary>
    /// Interaction logic for ChangeAppearance.xaml
    /// </summary>
    public partial class ChangeAppearance : Window
    {
        public ChangeAppearance()
        {
            InitializeComponent();
        }

        /// <summary>
        /// Selects game board style (green/blue)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void BoardList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var options = ((GameOptions)((ObjectDataProvider)this.DataContext).Data);
            options.ActiveThemeName = e.AddedItems.Count == 1 ? ((ListBoxItem)e.AddedItems[0]).Name : options.ActiveThemeName;
            if (Properties.Settings.Default.ChooseGameStyleAndBoardRandom)
            {
                options.RandomGameStyleAndBoard = false;
            }
        }

        /// <summary>
        /// Selects game style (mines/flowers)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void IconList_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            var options = ((GameOptions)((ObjectDataProvider)this.DataContext).Data);
            options.ActiveIconName = e.AddedItems.Count == 1 ? ((ListBoxItem)e.AddedItems[0]).Name : options.ActiveIconName;
            if (Properties.Settings.Default.ChooseGameStyleAndBoardRandom)
            {
                options.RandomGameStyleAndBoard = false;
            }
        }
    }
}
